﻿@using WebShop.Infrastructure;

@using WebShop.ViewModels

@model WebShop.ViewModels.UserWithRoles

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@section scripts
{
    <script src="@Url.Script("jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Script("jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>User</legend>
        @Html.HiddenFor(model => model.User.UserId)
        <div class="editor-label">
            @Html.LabelFor(model => model.User.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.UserName)
            @Html.ValidationMessageFor(model => model.User.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Email)
            @Html.ValidationMessageFor(model => model.User.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Comments)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Comments)
            @Html.ValidationMessageFor(model => model.User.Comments)
        </div>

        @Html.HiddenFor(model => model.User.CreatedDate)
        @Html.HiddenFor(model => model.User.LastLoginDate)

        <div class="editor-label">
            @Html.LabelFor(model => model.User.IsActivated)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.IsActivated)
            @Html.ValidationMessageFor(model => model.User.IsActivated)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.IsLockedOut)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.IsLockedOut)
            @Html.ValidationMessageFor(model => model.User.IsLockedOut)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.ContactName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.ContactName)
            @Html.ValidationMessageFor(model => model.User.ContactName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Address)
            @Html.ValidationMessageFor(model => model.User.Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.City)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.City)
            @Html.ValidationMessageFor(model => model.User.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Region)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Region)
            @Html.ValidationMessageFor(model => model.User.Region)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.PostalCode)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.PostalCode)
            @Html.ValidationMessageFor(model => model.User.PostalCode)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Country)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Country)
            @Html.ValidationMessageFor(model => model.User.Country)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Phone)
            @Html.ValidationMessageFor(model => model.User.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.User.Fax)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.Fax)
            @Html.ValidationMessageFor(model => model.User.Fax)
        </div>

    </fieldset>
    
    <fieldset>
        <legend>Roles</legend>        
            @for (int i = 0; i < Model.Roles.Count; i++)
            {
                <div>
                    @Html.CheckBoxFor(model => model.Roles[i].Participate)
                    @Html.DisplayFor(model => model.Roles[i].Name)
                    @Html.HiddenFor(model => model.Roles[i].Name)
                </div>
            }
    </fieldset>
    
    <p>
        <input type="submit" value="Save" />
    </p>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
